@charset "UTF-8";


/*doc
---
title: "Get translations"
name: message
category: Docs
subcategory: Functions
---

Retrieve message from translation map.

#### Source {get-translations-source}

```scss
@function message($theme, $key) {
  $message-key: $theme + ':' + $key;

  @if not map-has-key($messages, $message-key) {
    @error 'No key `#​{$message-key}` found.';
  }

  @return map-get($messages, $message-key);
}
```

#### Parameters {get-translations-parameters}

| Name     | Description                                       | Type     | Default value |
| -------- | ------------------------------------------------- | -------- | ------------- |
| `$theme` | Either `advice`, `error`, `warning` or `obsolete` | `String` | —             |
| `$key`   | Key to find message for                           | `String` | —             |

##### Used by  {get-translations-usedby}

- [`base-content()` mixin](#Mixins-base-content)
- [`message()` mixin](#Mixins-message)
*/
@function message($theme, $key) {
  $message-key: $theme + ':' + $key;

  @if not map-has-key($messages, $message-key) {
    @error 'No key `#{$message-key}` found.';
  }

  @return map-get($messages, $message-key);
}


/*doc
---
title: "Get theme configuration"
name: theme-conf
category: Docs
subcategory: Functions
---

Helper function to easily access a theme configuration.

#### Source {get-theme-configuration-source}

```scss
@function theme-conf($theme, $key) {
  @return map-get(map-get($themes, $theme), $key);
}
```

#### Parameters {get-theme-configuration-parameters}

| Name     | Description                                          | Type     | Default value |
| -------- | ---------------------------------------------------- | -------- | ------------- |
| `$theme` | Either `advice`, `error`, `warning` or `obsolete`    | `String` | —             |
| `$key`   | Data to get: `color`, `index` or `background-offset` | `String` | —             |

#### Example {get-theme-configuration-example}

Get color from error theme.

```sass
.selector {
  color: theme-conf('error', 'color');
}
```

```css
.selector {
  color: #911;
}
```

##### Used by {get-theme-configuration-usedby}

- [`base-content()` mixin](#Mixins-base-content)
- [`a11y()` mixin](#Mixins-a11y)
- [`%a11y-#​{$theme}` placeholder](#Placeholders-messages-level-styles)
*/
@function theme-conf($theme, $key) {
  @return map-get(map-get($themes, $theme), $key);
}


/*doc
---
title: "Check level to display"
name: is-level-enough
category: Docs
subcategory: Functions
---

Test whether `$level` is high enough to be displayed by comparing its index to `$minimum-level`'s.

#### Source {check-level-source}

```scss
@function is-level-enough($level) {
  $levels: map-keys($themes);
  @return index($levels, $level) <= index($levels, $minimum-level);
}
```

#### Parameters {check-level-parameters}

| Name     | Description                                       | Type     | Default value |
| -------- | ------------------------------------------------- | -------- | ------------- |
| `$level` | Either `advice`, `error`, `warning` or `obsolete` | `String` | —             |

##### Used by {check-level-usedby}

- [`base-content()` mixin](#Mixins-base-content)
- [`item()` mixin](#Mixins-item)
*/
@function is-level-enough($level) {
  $levels: map-keys($themes);
  @return index($levels, $level) <= index($levels, $minimum-level);
}


/*doc
---
title: "Escape attr()"
name: replace-attr
category: Docs
subcategory: Functions
---

Ensures CSS `attr()` function will render the expected value, instead of being output as a string.

#### Source {escape-attr-source}

```scss
@function replace-attr($message) {
  $has-attr: str-index($message, 'attr(');
  $first-paren: str-index($message, ')');

  @if not $has-attr {
    @return $message;
  }

  $first-chunk: str-slice($message, 1, $has-attr - 1);
  $last-chunk: str-slice($message, $first-paren + 1);

  $result: ();

  @if str-length($first-chunk) > 0 {
    $result: append($result, $first-chunk);
  }

  $result: append($result, unquote(str-slice($message, $has-attr, $first-paren)));

  @if str-length($last-chunk) > 0 {
    $result: append($result, replace-attr($last-chunk));
  }

  @return $result;
}
```

#### Parameters {escape-attr-parameters}

| Name       | Description       | Type     | Default value |
| ---------- | ----------------- | -------- | ------------- |
| `$message` | Message to escape | `String` | —             |

#### Example {escape-attr-example}

```sass
.selector {
  content: replace-attr("ARIA role attr(role) should be unique, but this one is the second!");
}
```

```css
.selector {
  content: "ARIA role " attr(role) "should be unique, but this one is the second!";
}
```

##### Used by {escape-attr-usedby}

- [`message()` mixin](#Mixins-message)
*/
@function replace-attr($message) {
  $has-attr: str-index($message, 'attr(');
  $first-paren: str-index($message, ')');

  @if not $has-attr {
    @return $message;
  }

  $first-chunk: str-slice($message, 1, $has-attr - 1);
  $last-chunk: str-slice($message, $first-paren + 1);

  $result: ();

  @if str-length($first-chunk) > 0 {
    $result: append($result, $first-chunk);
  }

  $result: append($result, unquote(str-slice($message, $has-attr, $first-paren)));

  @if str-length($last-chunk) > 0 {
    $result: append($result, replace-attr($last-chunk));
  }

  @return $result;
}
